import request from '@/config/axios'
import { ProductData } from '@/api/product/types'

//商品分类
export const getCategoryListApi = (pId: number): Promise<IResponse> => {
  return request.get({ url: '/api/SyOperationController/selProductCategory', params:{ pId } })
}

//商品列表
export const getProductListApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/api/SyOperationController/selProduct', params })
}

//添加商品
export const getAddProductApi = (data: Partial<ProductData>): Promise<IResponse> => {
  return request.post({url: '/api/SyOperationController/addProduct', data })
}

//审核商品列表
export const getProcessProductListApi = (params: any): Promise<IResponse> => {
  return request.post({url: '/api/SyOperationController/getCommodityAudit', params})
}

//操作日志列表
export const getOperationLogListApi = (params: any): Promise<IResponse> => {
  return request.post({ url: '/api/personnel/selOperationLog', params })
}

//审核商品日志列表
export const getProcessProductLogApi = (params: any): Promise<IResponse> => {
  return request.post({ url: '/api/SyOperationController/selProductLog', params })
}

//查看个人商品
export const getProductChaKanApi = (microcircleId: string): Promise<IResponse> => {
  return request.get({ url: '/api/SyOperationController/selCommodityInfo', params: { microcircleId } })
}

//刪除個人商品
export const getDelPersonalProductApi = (productId: number): Promise<IResponse> => {
  return request.get({url: '/api/SyOperationController/upPersonalProductList', params: { productId }})
}
//编辑商品列表
export const getProductBianJiApi = (productId: string): Promise<IResponse> => {
  return request.get({ url: '/api/SyOperationController/selProducts', params: { productId } })
}
//保存编辑个人商品
export const savePersonalApi = (data: Partial<ProductData>): Promise<IResponse> => {
  return request.post({ url: '/api/SyOperationController/updProduct', data })
}

//刪除商品日誌
export const getDelOperationLogApi = (id: number): Promise<IResponse> => {
  return request.get({url: '/api/personnel/delOperationLog', params: { id }})
}

//修改上下架
export const getUpdProductSateApi = (state: number, productId: number ): Promise<IResponse> => {
  return request.post({ url: '/api/SyOperationController/updProductSate', params: { state, productId } })
}
//修改商品审核状态
export const upProductSateApi = (productSate: number, productId: number): Promise<IResponse> => {
  return request.post({ url: '/api/SyOperationController/upProductSate', params: {productSate,productId} })
}